﻿@{
    ViewBag.Title = "PermissionsSettings";
    Layout = "~/Views/Shared/_POContentLayout.cshtml";
}
 @section HeadIncluder
{
    <link rel="stylesheet" type="text/css" href=@Url.Content("~/Scripts/skins/default.css") />
}
<form id="GetForm" name="GetForm" method="get" >
    <div>
        <table class="tb-search mb10" style="width: 100%;">
            <tr>
                <td class="box " style="width: 75%;">
                    用户：<input type="text" class="input-style-txt form-input" readonly="readonly" id="txtUserName" name="UserName" value="" />
                    <input type="hidden" class="input-style-txt form-input" id="hUserID" name="hUserID" value="" />
                    &nbsp; <input type="button" id="btnFind" onclick="addUsers()" value="选择用户" class="btn btn-blue " />
                    <input type="button" id="btnAdd" onclick="add()" value="添加部门" class="btn btn-blue "> 
                </td>
            </tr>
        </table>
    </div>
    <div >
        <table class="table-list mt20">
            <thead>
                <tr>
                    <th>编号</th>
                    <th>部门编号</th>
                    <th>部门名称</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id="htmlContent">
                
            </tbody>
        </table>
    </div>
     
  </form>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery.form.js")'> </script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/lhgdialog.min.js")'> </script> 
    <script type="text/javascript">
        function onRefresh() {
            window.location.reload();
        } 
        function addUsers() {
            var url = '@Url.Action("EmployeeSelect", "Employee")';
            OpenSelectUserPop(url, RefreshValue);
        }
        function RefreshValue(selectPostList) {
            if (selectPostList != null || selectPostList != undefined) {
                var strNames = "";
                var strUserIDs = "";
                $.each(selectPostList, function (i, val) {
                    strNames = val.Name;
                    strUserIDs = val.UserID;
                    $("#txtUserName").val(strNames);
                    $("#hUserID").val(strUserIDs);
                });
                onRefreshUserBusinessPermissions();
            }
           
        }
        function onRefreshUserBusinessPermissions()
        { 
            var url ='@Url.Action("UCPermissionsSettings", "BusinessReport")' + '?userID=' + $("#hUserID").val();
            $.post(url, function (data) {
                $("#htmlContent").html(data);
            });
        }
        function add() {
            if ($("#hUserID").val() == "")
            {
                alert("请先选择赋予权限的用户");
                return;
            }
            var url = '@Url.Action("UCDepartmentSelect", "Form")';
            var hUserID = $("#hUserID").val();
            window.top.winObj = window;
            window.top.refresh = function (vals, txts) {
                var url = '@Url.Action("SavePermissionsSettings", "BusinessReport")';
                $.post(url, { userID: hUserID, DeptCode: vals, DeptName: txts }, function (data) {
                    onRefreshUserBusinessPermissions();
                });
            };
            window.top.oDG = $.dialog({
                lock: true,
                background: '#FFF',
                opacity: 0.5,
                id: 'esDialog',
                title: '部门选择',
                titleAlign: 'left',
                content: "url:" + url,
                width: 570,
                height: 300,
                btnBar: false,
                lockScroll: true
            });
        }  
    </script>



